The Art of Computer Programming, Volume 3: Sorting and Searching, Second Edition by Donald E. Knuth

The Art of Computer Programming, Volume 3: Sorting and Searching, Second Edition by Donald E. Knuth

Author:Donald E. Knuth [Knuth, Donald E.]
Language: eng
Format: epub, pdf
Publisher: Addison-Wesley Professional
Published: 1998-11-05T23:00:00+00:00


Fig. 5. A comparison tree that corresponds to binary search when N = 16.

When N is 16, the first comparison made by the algorithm is K : K8; this is represented by the root node in the figure. Then if K < K8, the algorithm follows the left subtree, comparing K to K4; similarly if K > K8, the right subtree is used. An unsuccessful search will lead to one of the external square nodes numbered through ; for example, we reach node if and only if K6 < K < K7.

The binary tree corresponding to a binary search on N records can be constructed as follows: If N = 0, the tree is simply . Otherwise the root node is



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.